﻿@{
	string FlowID = Request.QueryString["flowid"];
	string StepID = Request.QueryString["stepid"];
	string GroupID = Request.QueryString["groupid"];
	string TaskID = Request.QueryString["taskid"];
	string InstanceID = Request.QueryString["instanceid"];
	string DisplayModel = Request.QueryString["display"] ?? "0";
	string DBConnID = "06075250-30dc-4d32-bf97-e922cb30fac8";
	string DBTable = "OaWorkOverTime";
	string DBTablePK = "ID";
	string DBTableTitle = "";
	if(InstanceID.IsNullOrEmpty()){InstanceID = Request.QueryString["instanceid1"];}
	YJ.Platform.Dictionary BDictionary = new YJ.Platform.Dictionary();
	YJ.Platform.WorkFlow BWorkFlow = new YJ.Platform.WorkFlow();
	YJ.Platform.WorkFlowTask BWorkFlowTask = new YJ.Platform.WorkFlowTask();
	string fieldStatus = BWorkFlow.GetFieldStatus(FlowID, StepID);
	LitJson.JsonData initData = BWorkFlow.GetFormData(DBConnID, DBTable, DBTablePK, InstanceID, fieldStatus, "{\"oaworkovertime.applicationdate\":\"yyyy年MM月dd日\",\"oaworkovertime.startdate\":\"yyyy-MM-dd\",\"oaworkovertime.startdatehr\":\"HH:mm \",\"oaworkovertime.enddate\":\"yyyy-MM-dd\",\"oaworkovertime.enddatehr\":\"HH:mm \"}");
	string TaskTitle = BWorkFlow.GetFromFieldData(initData, DBTable, DBTableTitle);
}
<link href="~/Scripts/FlowRun/Forms/flowform.css" rel="stylesheet" type="text/css" />
<script src="~/Scripts/FlowRun/Forms/common.js" type="text/javascript" ></script>
<input type="hidden" id="Form_ValidateAlertType" name="Form_ValidateAlertType" value="1" />
<input type="hidden" id="OaWorkOverTime." name="OaWorkOverTime." value="@(TaskTitle.IsNullOrEmpty() ? BWorkFlow.GetAutoTaskTitle(FlowID, StepID, Request.QueryString["groupid"]) : TaskTitle)" />
<input type="hidden" id="Form_TitleField" name="Form_TitleField" value="OaWorkOverTime." />
<input type="hidden" id="Form_DBConnID" name="Form_DBConnID" value="06075250-30dc-4d32-bf97-e922cb30fac8" />
<input type="hidden" id="Form_DBTable" name="Form_DBTable" value="OaWorkOverTime" />
<input type="hidden" id="Form_DBTablePk" name="Form_DBTablePk" value="ID" />
<input type="hidden" id="Form_DBTableTitle" name="Form_DBTableTitle" value="" />
<input type="hidden" id="Form_AutoSaveData" name="Form_AutoSaveData" value="1" />
<textarea id="Form_DBTableTitleExpression" name="Form_DBTableTitleExpression" style="display:none;width:0;height:0;"></textarea>
<script type="text/javascript">
	var initData = @Html.Raw(BWorkFlow.GetFormDataJsonString(initData));
	var fieldStatus = "1"=="@Request.QueryString["isreadonly"]" ? {} : @Html.Raw(fieldStatus);
	var displayModel = '@DisplayModel';
	$(window).load(function (){
		formrun.initData(initData, "OaWorkOverTime", fieldStatus, displayModel);
	});
</script>
<script>
	var Hours = 0;
	// 给日期类对象添加日期差方法，返回日期与diff参数日期的时间差，单位为天
	Date.prototype.diff = function(start, end) {
		return(end.getTime() - start.getTime()) / (60 * 60 * 1000);
	}

	function DateDiff() {

		// 构造两个日期，分别是系统时间和2013/04/08 12:43:45

		var startVar = $("#OaWorkOverTime\\.StartDate").val();
		var endVar = $("#OaWorkOverTime\\.EndDate").val();
		var start = new Date(startVar);
		var end = new Date(endVar);
		var over = new Date().diff(start, end);
		if(over <= 0) {
			alert("请选择正确的结束日期");
		} else if(over < 8) {
			$(srcObj).val(0.5);
		} else if(over <= 24) {
			$(srcObj).val(1);
		} else {
			$(srcObj).val(parseInt((over / 24)));
		}
	}

	function check(e) {
		var re = /^\d+(?=\.{0,1}\d+$|$)/
		if(e.value != "") {
			if(!re.test(e.value)) {
				alert("请输入正确的数字");
				e.value = "";
				e.focus();
			}
		}

	}

	function clickdays() {
		try {
			var userid = document.getElementById("OaWorkOverTime.OwnerID").value;
			if(userid == undefined || userid == null || userid == '') {
				alert("请选择加班人员");
				return;
			}
			var type = $("input[type='radio']:checked").val();
			if(type.lenght == 0) {
				alert("请选择加班类型");
			}
			var statedate = document.getElementById("OaWorkOverTime.StartDate").value;
			var statedatehr = document.getElementById("OaWorkOverTime.StartDateHr").value;
			var enddate = document.getElementById("OaWorkOverTime.EndDate").value;
			var enddatehr = document.getElementById("OaWorkOverTime.EndDateHr").value;
			if(type == 0 && !(statedatehr == '' || statedatehr == null || statedatehr == undefined)) {
				if(timerange(statedatehr, "00:00", "17:00")) {
					alert("您的加班类型为平常日，起始日期必须在17:00之后");
					document.getElementById("OaWorkOverTime.StartDateHr").focus();
					document.getElementById("OaWorkOverTime.StartDateHr").value = "";
					return;
				};
			}
			var url = "/PlatformApi/OaDailyOffice/GetWorkOverDays?userid=" + userid + "&statedate=" + statedate + "&enddate=" + enddate + "&statedatehr=" + statedatehr + "&enddatehr=" + enddatehr;
			$.ajax({
				url: url,
				contentType: "application/json",
				type: "GET",
				dataType: "json",
				async: false,
				success: function(json) {
					if(json.status == 1) {
						document.getElementById("OaWorkOverTime.Days").value = json.data;
						document.getElementById("OaWorkOverTime.Hours").value = json.Hours;
						if(type == 0 && json.Hours < 1 && json.data == 0) {
							//alert("您的加班时间不足一小时，不予计算加班时间。");
							document.getElementById("OaWorkOverTime.Hours").value = 0;
							document.getElementById("OaWorkOverTime.EndDateHr").focus();
						}
					} else if(json.status == 2) {
						document.getElementById("OaWorkOverTime.Days").value = 0;
						document.getElementById("OaWorkOverTime.Hours").value = 0;
						alert(json.msg);
					} else {
						document.getElementById("OaWorkOverTime.Days").value = 0;
						document.getElementById("OaWorkOverTime.Hours").value = 0;
					}
				},
				error: function(json) {
					RoadUI.Core.showError(json);
				}
			});
		} catch(e) {
			alert(e.message);
		}
	}</script><p><input type="hidden" id="OaWorkOverTime.op" name="OaWorkOverTime.op" isflow="1" type1="flow_hidden" value="u_@(new YJ.Platform.WorkFlowTask().GetFirstSnderID(FlowID.ToGuid(), GroupID.ToGuid(), true))"/></p><p><br/></p><p><br/></p><table class="flowformtable tableF table table-bordered" data-sort="sortDisabled" cellspacing="0" cellpadding="0" align="center"><tbody><tr class="firstRow"><th rowspan="1" colspan="2" valign="middle" align="center"><span class="title">加 班 申 请</span></th></tr><tr><th class="titleT" rowspan="1" colspan="2" valign="middle" align="left"><p class="titleO">基本信息</p></th></tr><tr class="topTr"><td class="top" rowspan="1" colspan="1" valign="middle" align="left"><p class="txt">姓名</p><input type="text" type1="flow_org" id="OaWorkOverTime.OwnerID" name="OaWorkOverTime.OwnerID" value="u_@YJ.Platform.Users.CurrentUserID.ToString()" style="width:55%" more="1" isflow="1" class="mymember" title="" dept="0" station="0" user="1" workgroup="0" unit="0" rootid="@BWorkFlowTask.GetFirstSnderDeptID(FlowID.ToGuid(), GroupID.ToGuid())"/></td><td class="top" rowspan="1" colspan="1" style="word-break: break-all;" valign="middle" align="left"><p class="txt">所属公司</p><input type="text" type1="flow_org" id="OaWorkOverTime.DeptID" name="OaWorkOverTime.DeptID" value="@(YJ.Platform.Users.CurrentUnitID)" style="width:55%" more="0" isflow="1" class="mymember" title="" dept="1" station="0" user="0" workgroup="0" unit="1" rootid="04f12beb-d99d-43df-ac9a-3042957d6bda,2201dffb-8af1-49ab-8851-0451cbf18384,346d3dff-0332-4e27-8c51-852970765553,e58b515b-e52c-4287-b684-bbbe33f69f98,9b35b6dc-bfcb-4029-a5c0-ebbaa0d2de6c"/></td></tr><tr class="bottomTr"><td class="bottom" rowspan="1" valign="middle" align="left"><p class="txt">岗位</p><input type="text" id="OaWorkOverTime.Post" type1="flow_text" name="OaWorkOverTime.Post" value="" valuetype="0" align="left" isflow="1" class="mytext" title=""/></td><td class="bottom" rowspan="1" valign="middle" align="left"><p class="txt">申请时间</p><input type="text" type1="flow_datetime" id="OaWorkOverTime.ApplicationDate" name="OaWorkOverTime.ApplicationDate" value="@(YJ.Utility.DateTimeNew.LongDate)" format="yyyy年MM月dd日" defaultvalue="%40(YJ.Utility.DateTimeNew.LongDate)" istime="1" daybefor="0" dayafter="0" currentmonth="0" isflow="1" class="mycalendar" title=""/></td></tr><tr><th class="titleT" rowspan="1" colspan="2" valign="middle" align="left"><p class="titleO">加班信息</p></th></tr><tr class="topTr"><td class="Tradio top" rowspan="1" colspan="2" valign="middle" align="left"><p class="txt">加班类别</p><input type="radio" name="OaWorkOverTime.Type" id="OaWorkOverTime.Type_0" value="0" checked="checked" style="vertical-align:middle;" isflow="1" type1="flow_radio" onclick="onclick_0b428673b1fb386ad0350e6b8a468f8f(this);"/><label for="OaWorkOverTime.Type_0" style="vertical-align:middle;margin-right:3px;">平常日</label><input type="radio" name="OaWorkOverTime.Type" id="OaWorkOverTime.Type_1" value="1" style="vertical-align:middle;" isflow="1" type1="flow_radio" onclick="onclick_0b428673b1fb386ad0350e6b8a468f8f(this);"/><label for="OaWorkOverTime.Type_1" style="vertical-align:middle;margin-right:3px;">公休日</label><input type="radio" name="OaWorkOverTime.Type" id="OaWorkOverTime.Type_2" value="2" style="vertical-align:middle;" isflow="1" type1="flow_radio" onclick="onclick_0b428673b1fb386ad0350e6b8a468f8f(this);"/><label for="OaWorkOverTime.Type_2" style="vertical-align:middle;margin-right:3px;">节假日</label><script type="text/javascript">function onclick_0b428673b1fb386ad0350e6b8a468f8f(srcObj){try{var type=$("input[type='radio']:checked").val();
if(type==0)
{
document.getElementById("OaWorkOverTime.StartDateHr").value="17:00";
clickdays();
}else
{
document.getElementById("OaWorkOverTime.StartDateHr").value="08:00";
clickdays();
}}catch(e){}}</script></td></tr><tr><td rowspan="1" colspan="1" valign="middle" align="left"><p class="txt">起始日期</p><input type="text" type1="flow_datetime" id="OaWorkOverTime.StartDate" name="OaWorkOverTime.StartDate" value="@(YJ.Utility.DateTimeNew.ShortDate)" format="yyyy-MM-dd" defaultvalue="%40(YJ.Utility.DateTimeNew.ShortDate)" istime="1" daybefor="0" dayafter="0" currentmonth="0" isflow="1" class="mycalendar" title="" onchange="onchange_719d597ffafe31e9fbdd54ec1c786f6d (this);"/><script type="text/javascript">function onchange_719d597ffafe31e9fbdd54ec1c786f6d(srcObj){try{
var src=$(srcObj).val();
var time=TimeObjectUtil.formatterDate(new Date());
  var url = "/PlatformApi/OaDailyOffice/GetDataDays?data1="+src+"&data2="+time;
        $.ajax({
            url: url,
            contentType: "application/json",
            type: "GET",
            dataType: "json",
            success: function(json) {
                if(json.status==1){
if(json.data>1){
alert("加班日期不允许早于当前日期超过一天，请重新选择。");
document.getElementById("OaWorkOverTime.StartDate").value="";
document.getElementById("OaWorkOverTime.StartDate").focus();
};
                }
            },
            error: function(json) {
                  RoadUI.Core.showError(json);
            }
        });
clickdays();
}catch(e)
{
}}</script></td><td rowspan="1" colspan="1" valign="middle" align="left"><p class="txt">起始时间</p><input type="text" type1="flow_datetime" id="OaWorkOverTime.StartDateHr" name="OaWorkOverTime.StartDateHr" value="17:00" format="HH:mm " defaultvalue="17%3A00" istime="1" daybefor="0" dayafter="0" currentmonth="0" isflow="1" class="mycalendar" title="" onblur="onblur_06f55d5f1b7a3aa2b8a6972b1eb974e1 (this);"/><script type="text/javascript">function onblur_06f55d5f1b7a3aa2b8a6972b1eb974e1(srcObj){try{ 
clickdays();}
catch(e){}}</script></td></tr><tr><td rowspan="1" colspan="1" valign="middle" align="left"><p class="txt">结束日期</p><input type="text" type1="flow_datetime" id="OaWorkOverTime.EndDate" name="OaWorkOverTime.EndDate" value="" format="yyyy-MM-dd" defaultvalue="" istime="1" daybefor="0" dayafter="0" currentmonth="0" isflow="1" class="mycalendar" title="" onchange="onchange_ebb0fbb58635e3754f4b0d49a1434b46 (this);"/><script type="text/javascript">function onchange_ebb0fbb58635e3754f4b0d49a1434b46(srcObj){clickdays();}</script></td><td rowspan="1" colspan="1" valign="middle" align="left"><p class="txt">结束时间</p><input type="text" type1="flow_datetime" id="OaWorkOverTime.EndDateHr" name="OaWorkOverTime.EndDateHr" value="" format="HH:mm " defaultvalue="" istime="1" daybefor="0" dayafter="0" currentmonth="0" isflow="1" class="mycalendar" title="" onblur="onblur_b8c663a765c9cd28b73dd111e15e2af5 (this);"/><script type="text/javascript">function onblur_b8c663a765c9cd28b73dd111e15e2af5(srcObj){try{
clickdays();
}catch(e)
{}}</script></td></tr><tr><td rowspan="1" colspan="2" valign="middle" align="left"><p class="txt">加班天数</p><input type="text" id="OaWorkOverTime.Days" type1="flow_text" name="OaWorkOverTime.Days" value="" placeholder="加班天数" style="width:15%;text-align:left;padding-right:3px;" valuetype="4" align="left" isflow="1" class="mytext" title=""/> 天 <input type="text" id="OaWorkOverTime.Hours" type1="flow_text" name="OaWorkOverTime.Hours" value="" placeholder="加班小时数" style="width:15%;text-align:left;padding-right:3px;" valuetype="4" align="left" isflow="1" class="mytext" title=""/> 小时</td></tr><tr class="bottomTr"><td class="bottom" rowspan="1" colspan="2" valign="middle" align="left"><p class="txt">加班事由</p><textarea isflow="1" type1="flow_textarea" id="OaWorkOverTime.Reason" name="OaWorkOverTime.Reason" class="mytext" style=" height:40px;"></textarea></td></tr></tbody></table>